/*******************************************************************

  Source file name : os.h

  Description: 
	OS support APIs for all applications of integrating CTI's CA.
 
  COPYRIGHT (C) Compunicate Technologies, Inc. 2003-2005

*********************************************************************/

#ifndef _OS_H_
#define _OS_H_
#include "cacore.h"

typedef	ULONG	OS_TASK_ID_M;
typedef	ULONG	OS_SEMAPHORE_M;
typedef	ULONG	OS_MAILBOX_M;

typedef struct
{
	WORD        msg_length;
	WORD        reserved;
	BYTE*       pData;	
	INT         type;
}OS_MSG;

//PVOID OS_Malloc(ULONG uSize);
//VOID  OS_Free(PVOID pvMemory);

#define CTI_LIB_FILE

#ifndef CTI_LIB_FILE
PVOID __OS_Calloc(ULONG uSize, int num, char* file, int line, char* func );
PVOID __OS_Malloc(ULONG uSize, char* file, int line, char* func);
VOID  __OS_Free(PVOID pvMemory, char* file, int line, char* func );
#define OS_Malloc(size) __OS_Malloc(size, __FILE__, __LINE__, (char*)__FUNCTION__ )
#define OS_Calloc(size,num) __OS_Calloc(size,num,__FILE__, __LINE__, (char*)__FUNCTION__ )
#define OS_Free(ptr) __OS_Free(ptr,__FILE__,__LINE__, (char*)__FUNCTION__ )
#else
PVOID OS_Malloc(ULONG uSize);
PVOID OS_Calloc(ULONG uSize, INT num );
VOID  OS_Free(PVOID pvMemory);
#endif

OS_TASK_ID_M OS_Task_Create(VOID(*task)(PVOID arg),INT iPriority,INT iStackSize);

OS_SEMAPHORE_M OS_Create_Semaphore(ULONG uInitialValue);

VOID OS_Signal_Semaphore(OS_SEMAPHORE_M uSemaphore);

VOID OS_Wait_Semaphore(OS_SEMAPHORE_M uSemaphore);

VOID OS_Task_Delay(INT iTimeInMilliSeconds);

SINT  OS_Send_Message(OS_MAILBOX_M uMailbox, OS_MSG * pstMsg);

OS_MSG * OS_Receive_Message(OS_MAILBOX_M uMailbox);

void OS_Assert(CHAR *file, INT line);

void OS_Print(CHAR *Format_p, ...);

#endif	/*_OS_H_*/
